home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1993, 1994 Marc Parmet.
- * This file is part of the Macintosh port of GNU Emacs.
- *
- * GNU Emacs is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
- #if defined(THINK_C)
- #include <MacHeaders>
- #else
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <Windows.h>
- #include <Files.h>
- #include <Errors.h>
- #endif
-
- int
- FSSpec2unixfn_internal(FSSpec *spec,Handle *s)
- {
- short err;
- long parID;
- CInfoPBRec pb;
- char *alloca();
- struct component {
- struct component *next;
- unsigned char s[32];
- } *component_list,*a;
-
- *s = 0L;
- a = (struct component *)alloca(sizeof(struct component));
- a->next = 0L;
- component_list = a;
- pstrcpy(a->s,spec->name);
- slashes_to_colons(a->s+1,a->s[0]);
- parID = spec->parID;
-
- while (1) {
- a = (struct component *)alloca(sizeof(struct component));
- pb.dirInfo.ioFDirIndex = -1;
- pb.dirInfo.ioNamePtr = a->s;
- pb.dirInfo.ioVRefNum = spec->vRefNum;
- pb.dirInfo.ioDrDirID = parID;
- err = PBGetCatInfo(&pb,0);
- if (err == fnfErr) break;
- if (err != noErr) return err;
-
- a->next = component_list;
- component_list = a;
- slashes_to_colons(a->s+1,a->s[0]);
- parID = pb.dirInfo.ioDrParID;
- }
-
- *s = NewHandle(0);
- err = MemError();
- if (err) return err;
- while (component_list != 0L) {
- err = PtrAndHand("/",*s,1);
- if (err) { DisposHandle(*s); *s = 0L; return err; }
- err = PtrAndHand(component_list->s+1,*s,component_list->s[0]);
- if (err) { DisposHandle(*s); *s = 0L; return err; }
- component_list = component_list->next;
- }
-
- err = PtrAndHand("",*s,1);
- if (err) { DisposHandle(*s); *s = 0L; return err; }
- return 0;
- }
-